package com.magic.item.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.magic.item.mapper.UserMapper;
import com.magic.item.pojo.User;
import com.magic.item.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lan.jianyuan
 * @create 2021-03-24-15:39
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    
    @Override
    public PageInfo<User> getPageInfo(String keyword, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<User> users = userMapper.selectExample(keyword);
        return new PageInfo<>(users);
    }
    @Override
    public void updateUser(User user) {
        this.userMapper.updateByPrimaryKey(user);
    }
    
    
    @Override
    public void deleteUser(Long uid) {
        this.userMapper.deleteUser(uid);
    }
    
    @Override
    public List<User> queryUserById(Long uid) {
        return this.userMapper.selectUserById(uid);
    }
}
